<template>
  <div id="app">
    <div id="nav">
      <router-link :to="{name:'Home'}">Home</router-link>|
      <router-link :to="{name:'About',params: { name: 'jace' }}">About</router-link>
    </div>
    <!-- <transition-group name="router">
      <router-view key="default"></router-view>
      <router-view key="email" name="email"></router-view>
      <router-view key="tel" name="tel"></router-view>
    </transition-group>-->
    <transition-group :name="transitionName">
      <router-view key="default"></router-view>
      <router-view key="email" name="email"></router-view>
      <router-view key="tel" name="tel"></router-view>
    </transition-group>
  </div>
</template>
<script>
export default {
  data() {
    return {
      transitionName: "",
    };
  },
  watch: {
    $route(to, from) {
      if (to.query && to.query.transitionName) {
        console.log('$route watch',to);
        this.transitionName = to.query.transitionName;
      }
    }
  },
};
</script>
<style>
/**
页面进入
 */
.router-enter {
  opacity: 0;
}

.router-enter-active {
  transition: opacity 1s ease;
}

.router-enter-to {
  opacity: 1;
}
/**
页面离开
 */
.router-leave {
  opacity: 1;
}
.router-leave-active {
  transition: opacity 1s ease;
}

.router-leave-to {
  opacity: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
</style>
